/* 
2  * jQuery File Upload Plugin JS Example 8.9.1 
3  * https://github.com/blueimp/jQuery-File-Upload 
4  * 
5  * Copyright 2010, Sebastian Tschan 
6  * https://blueimp.net 
7  * 
8  * Licensed under the MIT license: 
9  * http://www.opensource.org/licenses/MIT 
10  */  
 
 /* global $, window */ 
 
 
 $(function () { 
     'use strict'; 
 
     // Initialize the jQuery File Upload widget: 
     $('#fileupload').fileupload({ 
         // Uncomment the following to send cross-domain cookies: 
         //xhrFields: {withCredentials: true}, 
        url: '/GX_IRAP/page/common/File/doAdd1' 
     }); 

 
     // Enable iframe cross-domain access via redirect option: 
     $('#fileupload').fileupload( 
         'option', 
         'redirect', 
         window.location.href.replace( 
             /\/[^\/]*$/, 
             '/cors/result.html?%s' 
         ) 
     ); 
 
     //'blueimp.github.io'
     if (window.location.hostname === 'localhost') { 
    	 // Demo settings: 
         $('#fileupload').fileupload('option', { 
             url: '/GX_IRAP/page/common/File/doAdd1', 
             // Enable image resizing, except for Android and Opera, 
             // which actually support image resizing, but fail to 
             // send Blob objects via XHR requests: 
             disableImageResize: /Android(?!.*Chrome)|Opera/ 
                 .test(window.navigator.userAgent)
             /* 
                 , 
                 maxFileSize: 104857600
                 ,
             maxNumberOfFiles:1*/
            // acceptFileTypes: /(\.|\/)(gif|jpe?g|png|zip)$/i 
        }); 
         // Upload server status check for browsers with CORS support: 
         if ($.support.cors) { 
            $.ajax({ 
                 url: '/GX_IRAP/page/common/File/doAdd1', 
                 type: 'HEAD' 
             }).fail(function () { 
                /* $('<div class="alert alert-danger"/>') 
                     .text('Upload server currently unavailable - ' + 
                             new Date()) 
                     .appendTo('#fileupload'); */
             });  
         } 
     } else { 
        // Load existing files: 
         $('#fileupload').addClass('fileupload-processing'); 
        // alert( $('#fileupload').fileupload('option', 'url'));
         $.ajax({ 
             // Uncomment the following to send cross-domain cookies: 
             //xhrFields: {withCredentials: true}, 
             url: $('#fileupload').fileupload('option', 'url'), 
             dataType: 'json', 
             context: $('#fileupload')[0] 
         }).always(function () { 
             $(this).removeClass('fileupload-processing'); 
         }).done(function (result) { 
        	 $(this).fileupload('option', 'done') 
                 .call(this, $.Event('done'), {result: result}); 
         }); 
     } 
 
 
 }); 
